﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Quester.Models;

namespace Quester.Controllers
{
    public class ErrorController : Controller
    {
        //
        // GET: /Error/

        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Error404()
        {
            return View();
        }

        public ActionResult UncownError(ExceptionContext filterContext)
        {
            ErrorModel model;
            if (filterContext.Exception != null)
            {
                model = new ErrorModel()
                {
                    Exception = filterContext.Exception.ToString(),
                    Message = filterContext.Exception.Message,
                    StackTrace = filterContext.Exception.StackTrace
                };

                model.Message = model.Message.Replace(" at ", "\r\n __at ");
            }
            else
            {
                model = new ErrorModel()
                {
                    Exception = "Uncown exeption",
                    Message = "No message",
                    StackTrace = "No stackTrace data"
                };
            }

            return View(model);
        }

        public ActionResult Error500()
        {
            return View();
        }
    }
}
